
package com.yxinsur.imc.business.enums;

import com.yxinsur.imc.common.utils.StringUtils;
import lombok.Getter;

@Getter
public enum GenderType {
    /**
     * 男
     */
    M("M,男,男性", "男"),

    /**
     * 女
     */
    F("F,女,女性", "女");


    private String keyNames;

    private String keyName;

    private GenderType(String keyNames, String keyName) {
        this.keyNames = keyNames;
        this.keyName = keyName;
    }

    public String getKeyNames() {
        return keyNames;
    }

    public String getKeyName() {
        return keyName;
    }

    public static String getValueByKeyName(String keyName) {
        String keyValue = null;
        if (StringUtils.isNotBlank(keyName)) {
            for (GenderType c : GenderType.values()) {
                if (c.getKeyNames().contains(keyName)) {
                    keyValue = c.name();
                    break;
                }
            }
        }
        return keyValue;
    }

    public static String getKeyNameByValue(String value) {
        String keyValue = null;
        if (StringUtils.isNotBlank(value)) {
            for (GenderType c : GenderType.values()) {
                if (c.getKeyNames().contains(value)) {
                    keyValue = c.getKeyName();
                }
            }
        }
        return keyValue;
    }

}
